home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / e_os300b / ex_joy / exampl18.asm next >
Encoding:
Assembly Source File  |  1996-12-02  |  3.8 KB  |  137 lines

  1. ;╔══════════════════════════════════════════════════════════════════════════╗
  2. ;║                                                                          ║
  3. ;║ This example show how to use the Joystick library                        ║
  4. ;║                                                                          ║
  5. ;║                                                                          ║
  6. ;║                                                                          ║
  7. ;║ Tabs : 13 21 29 37                                                       ║
  8. ;║                                                                          ║
  9. ;╚══════════════════════════════════════════════════════════════════════════╝
  10.  
  11. Locals
  12. .386
  13. CODE32 SEGMENT PUBLIC PARA 'CODE' USE32
  14. ASSUME  CS:CODE32,DS:CODE32,ES:CODE32
  15.  
  16. INCLUDE ..\RESOURCE\EOS.INC
  17.  
  18. Msg_Good    db '    ■ Joystick detected',10,13,36
  19. Msg_Bad     db '    ■ Joystick not found',10,13,36
  20. Msg_Upper   db '    ■ Move joystick to UPPER LEFT and press FIRE',10,13,36
  21. Msg_Lower   db '    ■ Move joystick to LOWER RIGHT and press FIRE',10,13,36
  22. Msg_Center  db '    ■ Move joystick to CENTER and press FIRE',10,13,36
  23.  
  24. Flag        db '    ■ Left=    Right=    Up=    Down=    Fire1=    Fire2=    - Press ESC to Quit',13,0,0
  25.  
  26. _fire1      = 47
  27. _fire2      = 57
  28. _left       = 11
  29. _right      = 21
  30. _up         = 28
  31. _down       = 37
  32.  
  33. Addr_Joy1   dd 0
  34.  
  35. Start32:
  36.             call Init_Joystick
  37.  
  38.             call Detect_Joystick
  39.             test eax,Analog_A
  40.             jne @@cont
  41.  
  42.             mov ah,Exit_Error
  43.             mov edx,O Msg_Bad
  44.             Int_EOS
  45.  
  46. @@cont:
  47.             mov ah,9
  48.             mov edx,O Msg_Good
  49.             int 21h
  50.  
  51.             mov ax,Analog_A
  52.             call Add_Joystick
  53.             mov [Addr_Joy1],esi
  54.  
  55. @@calibrate:
  56.             mov ah,Use_Int_09
  57.             mov bx,On
  58.             Int_EOS
  59.  
  60.             mov ah,9
  61.             mov edx,O Msg_Upper
  62.             int 21h
  63. @@Upper_Left:
  64.             cmp [Key_Map+Escape],On
  65.             je @@exit
  66.             mov esi,[Addr_Joy1]
  67.             call Upper_Left
  68.             jc @@Upper_Left
  69.  
  70.             mov ah,9
  71.             mov edx,O Msg_Lower
  72.             int 21h
  73. @@Lower_Right:
  74.             cmp [Key_Map+Escape],On
  75.             je @@exit
  76.             mov esi,[Addr_Joy1]
  77.             call Lower_Right
  78.             jc @@Lower_Right
  79.  
  80.             mov ah,9
  81.             mov edx,O Msg_Center
  82.             int 21h
  83. @@Center:
  84.             cmp [Key_Map+Escape],On
  85.             je @@exit
  86.             mov esi,[Addr_Joy1]
  87.             call Center
  88.             jc @@Center
  89.  
  90. @@again:
  91.             call Update_Joystick
  92.  
  93.             mov D [flag+_fire1],'    '
  94.             mov D [flag+_fire2],'    '
  95.             mov D [flag+_left],'    '
  96.             mov D [flag+_right],'    '
  97.             mov D [flag+_up],'    '
  98.             mov D [flag+_down],'    '
  99.             mov esi,[Addr_Joy1]
  100.  
  101.             cmp [esi.Joy.J_Fire_1],On
  102.             jne @@Ok102
  103.             mov D [flag+_fire1],'  nO'
  104. @@Ok102:
  105.             cmp [esi.Joy.J_Fire_2],On
  106.             jne @@Ok103
  107.             mov D [flag+_fire2],'  nO'
  108. @@Ok103:
  109.             cmp [esi.Joy.J_Current_Left],On
  110.             jne @@Ok104
  111.             mov D [flag+_left],'  nO'
  112. @@Ok104:
  113.             cmp [esi.Joy.J_Current_Right],On
  114.             jne @@Ok105
  115.             mov D [flag+_right],'  nO'
  116. @@Ok105:
  117.             cmp [esi.Joy.J_Current_Up],On
  118.             jne @@Ok106
  119.             mov D [flag+_up],'  nO'
  120. @@Ok106:
  121.             cmp [esi.Joy.J_Current_Down],On
  122.             jne @@Ok107
  123.             mov D [flag+_down],'  nO'
  124. @@Ok107:
  125.             lea edx,Flag
  126.             mov ah,Direct_Send
  127.             Int_EOS
  128.  
  129.             cmp [Key_Map+Escape],On
  130.             jne @@again
  131.  
  132. @@exit:
  133.             mov ax,4c00h
  134.             int 21h
  135.  
  136.             CODE32 ENDS
  137.             END